CSharpTest.Net
Complete Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Threading Namespace > WorkQueue<T> Class : Complete Method

completePending
True to complete enqueued activities
timeout
The timeout to wait for a thread before Abort() is called

Glossary Item Box

Waits for all executing tasks to complete and then exists all threads, If completePending is false no more tasks will begin, if true threads will continue to pick up tasks and run until the queue is empty. The timeout period is used to join each thread in turn, if the timeout expires that thread will be aborted.

Syntax

Visual Basic (Declaration) 
Public Function Complete( _
   ByVal completePending As Boolean, _
   ByVal timeout As Integer _
) As Boolean
C# 
public bool Complete( 
   bool completePending,
   int timeout
)

Parameters

completePending
True to complete enqueued activities
timeout
The timeout to wait for a thread before Abort() is called

Exceptions

ExceptionDescription
System.ApplicationExceptionThe exception that is thrown when a non-fatal application error occurs.

Example

Library/Library.Test/TestWorkQueue.cs

C#Copy Code
int[] counter = new int[1];
using (WorkQueue<int[]> worker = new WorkQueue<int[]>(ProcessOne, Math.Max(2, Environment.ProcessorCount)))
{
    for (int i = 0; i < 1000; i++)
        worker.Enqueue(counter);
    worker.Complete(false, 10);
}
Assert.AreNotEqual(0, counter[0]);
VB.NETCopy Code
Dim counter As Integer() = New Integer(1) {}
Using worker As New WorkQueue(Of Integer())(ProcessOne, Math.Max(2, Environment.ProcessorCount))
    Dim i As Integer = 0
    While i < 1000
        worker.Enqueue(counter)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    worker.Complete(False, 10)
End Using
Assert.AreNotEqual(0, counter(0))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

WorkQueue<T> Class
WorkQueue<T> Members

Used By

ThreadedBTreeTest.TestAtomicUpdate()
ThreadedBTreeTest.TestErrorsOnInsertAndDelete()
ThreadedBTreeTest.TestConcurrentCreateReadUpdateDelete8000()
Boolean SecureTransfer.Client.Upload(String,Int64,Stream)

Source Code

Library/Threading/WorkQueue.cs

Generated with Document! X 2011 by Innovasys